package com.panopset.gui;

import java.io.StringWriter;
import java.math.BigDecimal;
import java.util.StringTokenizer;
import java.util.Vector;

import com.panopset.Strings;
import com.panopset.Util;
import com.panopset.centralen.util.MathUtil;
import com.panopset.swing.Scaffolding;

/**
 * Property file editor id.
 * @author Karl Dinwiddie.
 *
 */
public class PVEID implements Comparable<PVEID> {

	private final String lbl;
	private String tip = "";
	private final String ky;
	private String order = "";
	
	
	public PVEID(final String key) {
		if (!Strings.isPopulated(key)) {
			throw new RuntimeException();
		}
		StringTokenizer st = new StringTokenizer(key, "@");
		lbl = st.nextToken();
		if (st.hasMoreElements()) {
			tip = st.nextToken();
		}
		if (st.hasMoreElements()) {
			order = st.nextToken();
		}
		ky = key;
	}
	
	public PVEID(final String label, final String tip, final String order) {
		this(label + "@" + tip + "@" + order);
	}
	
	public PVEID(final String label, final String tip) {
		this(label + "@" + tip);
	}
	
	public String getLabel() {
		return lbl;
	}
	
	@Override
	public String toString() {
		return ky;
	}
	
	public String getTip() {
		return tip;
	}

	@Override
	public int compareTo(PVEID o) {
		if (Strings.isPopulated(order)) {
			return order.compareTo(o.order);
		} else {
			return ky.compareTo(o.ky);
		}
	}
}
